package com.zhongfl.crm.lixiao.batch.jobs;

import com.zhongfl.crm.lixiao.batch.service.lx2crm.LxCreateChannelSyncService;
import com.zhongfl.crm.lixiao.batch.service.lx2crm.LxUpdateChannelSyncService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 励销->CRM 同步励销渠道到CRM
 *
 * @author zhang.zengke
 * @date 2018/9/20
 */
@Component
@Slf4j
public class LxChannelSyncJob extends JobService {

    @Resource
    private LxCreateChannelSyncService lxCreateChannelSyncService;

    @Resource
    private LxUpdateChannelSyncService lxUpdateChannelSyncService;

    @Override
    public boolean lock() {
        return true;
    }

    @Override
    public void start() {

        log.info("励销正式渠道新增同步服务开始");
        try {
            lxCreateChannelSyncService.syncCustomer();
        } catch (Exception e) {
            log.error("励销正式渠道新增同步服务出错: {}" , e.getMessage(),e );
        }
        log.info("励销正式渠道新增同步服务结束");

        log.info("励销正式渠道修改同步服务开始");
        try {
            lxUpdateChannelSyncService.syncLxUpdateChannelSync();
        } catch (Exception e) {
            log.error("励销正式渠道修改同步服务出错: {}" , e.getMessage(),e );
        }
        log.info("励销正式渠道修改同步服务结束");

    }
}
